1 /*
2  * frontend.h
3  *
4  * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5  *		    Ralph  Metzler <ralph@convergence.de>
6  *		    Holger Waechtler <holger@convergence.de>
7  *		    Andre Draszik <ad@convergence.de>
8  *		    for convergence integrated media GmbH
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; either version 2.1
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  *
24  */
25 
26 module libdvbv5_d.dvb_frontend;
27 
28 import core.sys.posix.sys.ioctl;
29 
30 extern (C):
31 
32 /**
33  * enum fe_caps - Frontend capabilities
34  *
35  * @FE_IS_STUPID:			There's something wrong at the
36  *					frontend, and it can't report its
37  *					capabilities.
38  * @FE_CAN_INVERSION_AUTO:		Can auto-detect frequency spectral
39  *					band inversion
40  * @FE_CAN_FEC_1_2:			Supports FEC 1/2
41  * @FE_CAN_FEC_2_3:			Supports FEC 2/3
42  * @FE_CAN_FEC_3_4:			Supports FEC 3/4
43  * @FE_CAN_FEC_4_5:			Supports FEC 4/5
44  * @FE_CAN_FEC_5_6:			Supports FEC 5/6
45  * @FE_CAN_FEC_6_7:			Supports FEC 6/7
46  * @FE_CAN_FEC_7_8:			Supports FEC 7/8
47  * @FE_CAN_FEC_8_9:			Supports FEC 8/9
48  * @FE_CAN_FEC_AUTO:			Can auto-detect FEC
49  * @FE_CAN_QPSK:			Supports QPSK modulation
50  * @FE_CAN_QAM_16:			Supports 16-QAM modulation
51  * @FE_CAN_QAM_32:			Supports 32-QAM modulation
52  * @FE_CAN_QAM_64:			Supports 64-QAM modulation
53  * @FE_CAN_QAM_128:			Supports 128-QAM modulation
54  * @FE_CAN_QAM_256:			Supports 256-QAM modulation
55  * @FE_CAN_QAM_AUTO:			Can auto-detect QAM modulation
56  * @FE_CAN_TRANSMISSION_MODE_AUTO:	Can auto-detect transmission mode
57  * @FE_CAN_BANDWIDTH_AUTO:		Can auto-detect bandwidth
58  * @FE_CAN_GUARD_INTERVAL_AUTO:		Can auto-detect guard interval
59  * @FE_CAN_HIERARCHY_AUTO:		Can auto-detect hierarchy
60  * @FE_CAN_8VSB:			Supports 8-VSB modulation
61  * @FE_CAN_16VSB:			Supporta 16-VSB modulation
62  * @FE_HAS_EXTENDED_CAPS:		Unused
63  * @FE_CAN_MULTISTREAM:			Supports multistream filtering
64  * @FE_CAN_TURBO_FEC:			Supports "turbo FEC" modulation
65  * @FE_CAN_2G_MODULATION:		Supports "2nd generation" modulation,
66  *					e. g. DVB-S2, DVB-T2, DVB-C2
67  * @FE_NEEDS_BENDING:			Unused
68  * @FE_CAN_RECOVER:			Can recover from a cable unplug
69  *					automatically
70  * @FE_CAN_MUTE_TS:			Can stop spurious TS data output
71  */
72 enum fe_caps
73 {
74     FE_IS_STUPID = 0,
75     FE_CAN_INVERSION_AUTO = 0x1,
76     FE_CAN_FEC_1_2 = 0x2,
77     FE_CAN_FEC_2_3 = 0x4,
78     FE_CAN_FEC_3_4 = 0x8,
79     FE_CAN_FEC_4_5 = 0x10,
80     FE_CAN_FEC_5_6 = 0x20,
81     FE_CAN_FEC_6_7 = 0x40,
82     FE_CAN_FEC_7_8 = 0x80,
83     FE_CAN_FEC_8_9 = 0x100,
84     FE_CAN_FEC_AUTO = 0x200,
85     FE_CAN_QPSK = 0x400,
86     FE_CAN_QAM_16 = 0x800,
87     FE_CAN_QAM_32 = 0x1000,
88     FE_CAN_QAM_64 = 0x2000,
89     FE_CAN_QAM_128 = 0x4000,
90     FE_CAN_QAM_256 = 0x8000,
91     FE_CAN_QAM_AUTO = 0x10000,
92     FE_CAN_TRANSMISSION_MODE_AUTO = 0x20000,
93     FE_CAN_BANDWIDTH_AUTO = 0x40000,
94     FE_CAN_GUARD_INTERVAL_AUTO = 0x80000,
95     FE_CAN_HIERARCHY_AUTO = 0x100000,
96     FE_CAN_8VSB = 0x200000,
97     FE_CAN_16VSB = 0x400000,
98     FE_HAS_EXTENDED_CAPS = 0x800000,
99     FE_CAN_MULTISTREAM = 0x4000000,
100     FE_CAN_TURBO_FEC = 0x8000000,
101     FE_CAN_2G_MODULATION = 0x10000000,
102     FE_NEEDS_BENDING = 0x20000000,
103     FE_CAN_RECOVER = 0x40000000,
104     FE_CAN_MUTE_TS = 0x80000000
105 }
106 
107 /*
108  * DEPRECATED: Should be kept just due to backward compatibility.
109  */
110 enum fe_type
111 {
112     FE_QPSK = 0,
113     FE_QAM = 1,
114     FE_OFDM = 2,
115     FE_ATSC = 3
116 }
117 
118 /**
119  * struct dvb_frontend_info - Frontend properties and capabilities
120  *
121  * @name:			Name of the frontend
122  * @type:			**DEPRECATED**.
123  *				Should not be used on modern programs,
124  *				as a frontend may have more than one type.
125  *				In order to get the support types of a given
126  *				frontend, use :c:type:`DTV_ENUM_DELSYS`
127  *				instead.
128  * @frequency_min:		Minimal frequency supported by the frontend.
129  * @frequency_max:		Minimal frequency supported by the frontend.
130  * @frequency_stepsize:		All frequencies are multiple of this value.
131  * @frequency_tolerance:	Frequency tolerance.
132  * @symbol_rate_min:		Minimal symbol rate, in bauds
133  *				(for Cable/Satellite systems).
134  * @symbol_rate_max:		Maximal symbol rate, in bauds
135  *				(for Cable/Satellite systems).
136  * @symbol_rate_tolerance:	Maximal symbol rate tolerance, in ppm
137  *				(for Cable/Satellite systems).
138  * @notifier_delay:		**DEPRECATED**. Not used by any driver.
139  * @caps:			Capabilities supported by the frontend,
140  *				as specified in &enum fe_caps.
141  *
142  * .. note:
143  *
144  *    #. The frequencies are specified in Hz for Terrestrial and Cable
145  *       systems.
146  *    #. The frequencies are specified in kHz for Satellite systems.
147  */
148 struct dvb_frontend_info
149 {
150     char[128] name;
151     fe_type type; /* DEPRECATED. Use DTV_ENUM_DELSYS instead */
152     uint frequency_min;
153     uint frequency_max;
154     uint frequency_stepsize;
155     uint frequency_tolerance;
156     uint symbol_rate_min;
157     uint symbol_rate_max;
158     uint symbol_rate_tolerance;
159     uint notifier_delay; /* DEPRECATED */
160     fe_caps caps;
161 }
162 
163 /**
164  * struct dvb_diseqc_master_cmd - DiSEqC master command
165  *
166  * @msg:
167  *	DiSEqC message to be sent. It contains a 3 bytes header with:
168  *	framing + address + command, and an optional argument
169  *	of up to 3 bytes of data.
170  * @msg_len:
171  *	Length of the DiSEqC message. Valid values are 3 to 6.
172  *
173  * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
174  * the possible messages that can be used.
175  */
176 struct dvb_diseqc_master_cmd
177 {
178     ubyte[6] msg;
179     ubyte msg_len;
180 }
181 
182 /**
183  * struct dvb_diseqc_slave_reply - DiSEqC received data
184  *
185  * @msg:
186  *	DiSEqC message buffer to store a message received via DiSEqC.
187  *	It contains one byte header with: framing and
188  *	an optional argument of up to 3 bytes of data.
189  * @msg_len:
190  *	Length of the DiSEqC message. Valid values are 0 to 4,
191  *	where 0 means no message.
192  * @timeout:
193  *	Return from ioctl after timeout ms with errorcode when
194  *	no message was received.
195  *
196  * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
197  * the possible messages that can be used.
198  */
199 struct dvb_diseqc_slave_reply
200 {
201     ubyte[4] msg;
202     ubyte msg_len;
203     int timeout;
204 }
205 
206 /**
207  * enum fe_sec_voltage - DC Voltage used to feed the LNBf
208  *
209  * @SEC_VOLTAGE_13:	Output 13V to the LNBf
210  * @SEC_VOLTAGE_18:	Output 18V to the LNBf
211  * @SEC_VOLTAGE_OFF:	Don't feed the LNBf with a DC voltage
212  */
213 enum fe_sec_voltage
214 {
215     SEC_VOLTAGE_13 = 0,
216     SEC_VOLTAGE_18 = 1,
217     SEC_VOLTAGE_OFF = 2
218 }
219 
220 /**
221  * enum fe_sec_tone_mode - Type of tone to be send to the LNBf.
222  * @SEC_TONE_ON:	Sends a 22kHz tone burst to the antenna.
223  * @SEC_TONE_OFF:	Don't send a 22kHz tone to the antenna (except
224  *			if the ``FE_DISEQC_*`` ioctls are called).
225  */
226 enum fe_sec_tone_mode
227 {
228     SEC_TONE_ON = 0,
229     SEC_TONE_OFF = 1
230 }
231 
232 /**
233  * enum fe_sec_mini_cmd - Type of mini burst to be sent
234  *
235  * @SEC_MINI_A:		Sends a mini-DiSEqC 22kHz '0' Tone Burst to select
236  *			satellite-A
237  * @SEC_MINI_B:		Sends a mini-DiSEqC 22kHz '1' Data Burst to select
238  *			satellite-B
239  */
240 enum fe_sec_mini_cmd
241 {
242     SEC_MINI_A = 0,
243     SEC_MINI_B = 1
244 }
245 
246 /**
247  * enum fe_status - Enumerates the possible frontend status.
248  * @FE_NONE:		The frontend doesn't have any kind of lock.
249  *			That's the initial frontend status
250  * @FE_HAS_SIGNAL:	Has found something above the noise level.
251  * @FE_HAS_CARRIER:	Has found a signal.
252  * @FE_HAS_VITERBI:	FEC inner coding (Viterbi, LDPC or other inner code).
253  *			is stable.
254  * @FE_HAS_SYNC:	Synchronization bytes was found.
255  * @FE_HAS_LOCK:	Digital TV were locked and everything is working.
256  * @FE_TIMEDOUT:	Fo lock within the last about 2 seconds.
257  * @FE_REINIT:		Frontend was reinitialized, application is recommended
258  *			to reset DiSEqC, tone and parameters.
259  */
260 enum fe_status
261 {
262     FE_NONE = 0x00,
263     FE_HAS_SIGNAL = 0x01,
264     FE_HAS_CARRIER = 0x02,
265     FE_HAS_VITERBI = 0x04,
266     FE_HAS_SYNC = 0x08,
267     FE_HAS_LOCK = 0x10,
268     FE_TIMEDOUT = 0x20,
269     FE_REINIT = 0x40
270 }
271 
272 /**
273  * enum fe_spectral_inversion - Type of inversion band
274  *
275  * @INVERSION_OFF:	Don't do spectral band inversion.
276  * @INVERSION_ON:	Do spectral band inversion.
277  * @INVERSION_AUTO:	Autodetect spectral band inversion.
278  *
279  * This parameter indicates if spectral inversion should be presumed or
280  * not. In the automatic setting (``INVERSION_AUTO``) the hardware will try
281  * to figure out the correct setting by itself. If the hardware doesn't
282  * support, the %dvb_frontend will try to lock at the carrier first with
283  * inversion off. If it fails, it will try to enable inversion.
284  */
285 enum fe_spectral_inversion
286 {
287     INVERSION_OFF = 0,
288     INVERSION_ON = 1,
289     INVERSION_AUTO = 2
290 }
291 
292 /**
293  * enum fe_code_rate - Type of Forward Error Correction (FEC)
294  *
295  *
296  * @FEC_NONE: No Forward Error Correction Code
297  * @FEC_1_2:  Forward Error Correction Code 1/2
298  * @FEC_2_3:  Forward Error Correction Code 2/3
299  * @FEC_3_4:  Forward Error Correction Code 3/4
300  * @FEC_4_5:  Forward Error Correction Code 4/5
301  * @FEC_5_6:  Forward Error Correction Code 5/6
302  * @FEC_6_7:  Forward Error Correction Code 6/7
303  * @FEC_7_8:  Forward Error Correction Code 7/8
304  * @FEC_8_9:  Forward Error Correction Code 8/9
305  * @FEC_AUTO: Autodetect Error Correction Code
306  * @FEC_3_5:  Forward Error Correction Code 3/5
307  * @FEC_9_10: Forward Error Correction Code 9/10
308  * @FEC_2_5:  Forward Error Correction Code 2/5
309  *
310  * Please note that not all FEC types are supported by a given standard.
311  */
312 enum fe_code_rate
313 {
314     FEC_NONE = 0,
315     FEC_1_2 = 1,
316     FEC_2_3 = 2,
317     FEC_3_4 = 3,
318     FEC_4_5 = 4,
319     FEC_5_6 = 5,
320     FEC_6_7 = 6,
321     FEC_7_8 = 7,
322     FEC_8_9 = 8,
323     FEC_AUTO = 9,
324     FEC_3_5 = 10,
325     FEC_9_10 = 11,
326     FEC_2_5 = 12
327 }
328 
329 /**
330  * enum fe_modulation - Type of modulation/constellation
331  * @QPSK:	QPSK modulation
332  * @QAM_16:	16-QAM modulation
333  * @QAM_32:	32-QAM modulation
334  * @QAM_64:	64-QAM modulation
335  * @QAM_128:	128-QAM modulation
336  * @QAM_256:	256-QAM modulation
337  * @QAM_AUTO:	Autodetect QAM modulation
338  * @VSB_8:	8-VSB modulation
339  * @VSB_16:	16-VSB modulation
340  * @PSK_8:	8-PSK modulation
341  * @APSK_16:	16-APSK modulation
342  * @APSK_32:	32-APSK modulation
343  * @DQPSK:	DQPSK modulation
344  * @QAM_4_NR:	4-QAM-NR modulation
345  *
346  * Please note that not all modulations are supported by a given standard.
347  *
348  */
349 enum fe_modulation
350 {
351     QPSK = 0,
352     QAM_16 = 1,
353     QAM_32 = 2,
354     QAM_64 = 3,
355     QAM_128 = 4,
356     QAM_256 = 5,
357     QAM_AUTO = 6,
358     VSB_8 = 7,
359     VSB_16 = 8,
360     PSK_8 = 9,
361     APSK_16 = 10,
362     APSK_32 = 11,
363     DQPSK = 12,
364     QAM_4_NR = 13
365 }
366 
367 /**
368  * enum fe_transmit_mode - Transmission mode
369  *
370  * @TRANSMISSION_MODE_AUTO:
371  *	Autodetect transmission mode. The hardware will try to find the
372  *	correct FFT-size (if capable) to fill in the missing parameters.
373  * @TRANSMISSION_MODE_1K:
374  *	Transmission mode 1K
375  * @TRANSMISSION_MODE_2K:
376  *	Transmission mode 2K
377  * @TRANSMISSION_MODE_8K:
378  *	Transmission mode 8K
379  * @TRANSMISSION_MODE_4K:
380  *	Transmission mode 4K
381  * @TRANSMISSION_MODE_16K:
382  *	Transmission mode 16K
383  * @TRANSMISSION_MODE_32K:
384  *	Transmission mode 32K
385  * @TRANSMISSION_MODE_C1:
386  *	Single Carrier (C=1) transmission mode (DTMB only)
387  * @TRANSMISSION_MODE_C3780:
388  *	Multi Carrier (C=3780) transmission mode (DTMB only)
389  *
390  * Please note that not all transmission modes are supported by a given
391  * standard.
392  */
393 enum fe_transmit_mode
394 {
395     TRANSMISSION_MODE_2K = 0,
396     TRANSMISSION_MODE_8K = 1,
397     TRANSMISSION_MODE_AUTO = 2,
398     TRANSMISSION_MODE_4K = 3,
399     TRANSMISSION_MODE_1K = 4,
400     TRANSMISSION_MODE_16K = 5,
401     TRANSMISSION_MODE_32K = 6,
402     TRANSMISSION_MODE_C1 = 7,
403     TRANSMISSION_MODE_C3780 = 8
404 }
405 
406 /**
407  * enum fe_guard_interval - Guard interval
408  *
409  * @GUARD_INTERVAL_AUTO:	Autodetect the guard interval
410  * @GUARD_INTERVAL_1_128:	Guard interval 1/128
411  * @GUARD_INTERVAL_1_32:	Guard interval 1/32
412  * @GUARD_INTERVAL_1_16:	Guard interval 1/16
413  * @GUARD_INTERVAL_1_8:		Guard interval 1/8
414  * @GUARD_INTERVAL_1_4:		Guard interval 1/4
415  * @GUARD_INTERVAL_19_128:	Guard interval 19/128
416  * @GUARD_INTERVAL_19_256:	Guard interval 19/256
417  * @GUARD_INTERVAL_PN420:	PN length 420 (1/4)
418  * @GUARD_INTERVAL_PN595:	PN length 595 (1/6)
419  * @GUARD_INTERVAL_PN945:	PN length 945 (1/9)
420  *
421  * Please note that not all guard intervals are supported by a given standard.
422  */
423 enum fe_guard_interval
424 {
425     GUARD_INTERVAL_1_32 = 0,
426     GUARD_INTERVAL_1_16 = 1,
427     GUARD_INTERVAL_1_8 = 2,
428     GUARD_INTERVAL_1_4 = 3,
429     GUARD_INTERVAL_AUTO = 4,
430     GUARD_INTERVAL_1_128 = 5,
431     GUARD_INTERVAL_19_128 = 6,
432     GUARD_INTERVAL_19_256 = 7,
433     GUARD_INTERVAL_PN420 = 8,
434     GUARD_INTERVAL_PN595 = 9,
435     GUARD_INTERVAL_PN945 = 10
436 }
437 
438 /**
439  * enum fe_hierarchy - Hierarchy
440  * @HIERARCHY_NONE:	No hierarchy
441  * @HIERARCHY_AUTO:	Autodetect hierarchy (if supported)
442  * @HIERARCHY_1:	Hierarchy 1
443  * @HIERARCHY_2:	Hierarchy 2
444  * @HIERARCHY_4:	Hierarchy 4
445  *
446  * Please note that not all hierarchy types are supported by a given standard.
447  */
448 enum fe_hierarchy
449 {
450     HIERARCHY_NONE = 0,
451     HIERARCHY_1 = 1,
452     HIERARCHY_2 = 2,
453     HIERARCHY_4 = 3,
454     HIERARCHY_AUTO = 4
455 }
456 
457 /**
458  * enum fe_interleaving - Interleaving
459  * @INTERLEAVING_NONE:	No interleaving.
460  * @INTERLEAVING_AUTO:	Auto-detect interleaving.
461  * @INTERLEAVING_240:	Interleaving of 240 symbols.
462  * @INTERLEAVING_720:	Interleaving of 720 symbols.
463  *
464  * Please note that, currently, only DTMB uses it.
465  */
466 enum fe_interleaving
467 {
468     INTERLEAVING_NONE = 0,
469     INTERLEAVING_AUTO = 1,
470     INTERLEAVING_240 = 2,
471     INTERLEAVING_720 = 3
472 }
473 
474 /* DVBv5 property Commands */
475 
476 enum DTV_UNDEFINED = 0;
477 enum DTV_TUNE = 1;
478 enum DTV_CLEAR = 2;
479 enum DTV_FREQUENCY = 3;
480 enum DTV_MODULATION = 4;
481 enum DTV_BANDWIDTH_HZ = 5;
482 enum DTV_INVERSION = 6;
483 enum DTV_DISEQC_MASTER = 7;
484 enum DTV_SYMBOL_RATE = 8;
485 enum DTV_INNER_FEC = 9;
486 enum DTV_VOLTAGE = 10;
487 enum DTV_TONE = 11;
488 enum DTV_PILOT = 12;
489 enum DTV_ROLLOFF = 13;
490 enum DTV_DISEQC_SLAVE_REPLY = 14;
491 
492 /* Basic enumeration set for querying unlimited capabilities */
493 enum DTV_FE_CAPABILITY_COUNT = 15;
494 enum DTV_FE_CAPABILITY = 16;
495 enum DTV_DELIVERY_SYSTEM = 17;
496 
497 /* ISDB-T and ISDB-Tsb */
498 enum DTV_ISDBT_PARTIAL_RECEPTION = 18;
499 enum DTV_ISDBT_SOUND_BROADCASTING = 19;
500 
501 enum DTV_ISDBT_SB_SUBCHANNEL_ID = 20;
502 enum DTV_ISDBT_SB_SEGMENT_IDX = 21;
503 enum DTV_ISDBT_SB_SEGMENT_COUNT = 22;
504 
505 enum DTV_ISDBT_LAYERA_FEC = 23;
506 enum DTV_ISDBT_LAYERA_MODULATION = 24;
507 enum DTV_ISDBT_LAYERA_SEGMENT_COUNT = 25;
508 enum DTV_ISDBT_LAYERA_TIME_INTERLEAVING = 26;
509 
510 enum DTV_ISDBT_LAYERB_FEC = 27;
511 enum DTV_ISDBT_LAYERB_MODULATION = 28;
512 enum DTV_ISDBT_LAYERB_SEGMENT_COUNT = 29;
513 enum DTV_ISDBT_LAYERB_TIME_INTERLEAVING = 30;
514 
515 enum DTV_ISDBT_LAYERC_FEC = 31;
516 enum DTV_ISDBT_LAYERC_MODULATION = 32;
517 enum DTV_ISDBT_LAYERC_SEGMENT_COUNT = 33;
518 enum DTV_ISDBT_LAYERC_TIME_INTERLEAVING = 34;
519 
520 enum DTV_API_VERSION = 35;
521 
522 enum DTV_CODE_RATE_HP = 36;
523 enum DTV_CODE_RATE_LP = 37;
524 enum DTV_GUARD_INTERVAL = 38;
525 enum DTV_TRANSMISSION_MODE = 39;
526 enum DTV_HIERARCHY = 40;
527 
528 enum DTV_ISDBT_LAYER_ENABLED = 41;
529 
530 enum DTV_STREAM_ID = 42;
531 enum DTV_ISDBS_TS_ID_LEGACY = DTV_STREAM_ID;
532 enum DTV_DVBT2_PLP_ID_LEGACY = 43;
533 
534 enum DTV_ENUM_DELSYS = 44;
535 
536 /* ATSC-MH */
537 enum DTV_ATSCMH_FIC_VER = 45;
538 enum DTV_ATSCMH_PARADE_ID = 46;
539 enum DTV_ATSCMH_NOG = 47;
540 enum DTV_ATSCMH_TNOG = 48;
541 enum DTV_ATSCMH_SGN = 49;
542 enum DTV_ATSCMH_PRC = 50;
543 enum DTV_ATSCMH_RS_FRAME_MODE = 51;
544 enum DTV_ATSCMH_RS_FRAME_ENSEMBLE = 52;
545 enum DTV_ATSCMH_RS_CODE_MODE_PRI = 53;
546 enum DTV_ATSCMH_RS_CODE_MODE_SEC = 54;
547 enum DTV_ATSCMH_SCCC_BLOCK_MODE = 55;
548 enum DTV_ATSCMH_SCCC_CODE_MODE_A = 56;
549 enum DTV_ATSCMH_SCCC_CODE_MODE_B = 57;
550 enum DTV_ATSCMH_SCCC_CODE_MODE_C = 58;
551 enum DTV_ATSCMH_SCCC_CODE_MODE_D = 59;
552 
553 enum DTV_INTERLEAVING = 60;
554 enum DTV_LNA = 61;
555 
556 /* Quality parameters */
557 enum DTV_STAT_SIGNAL_STRENGTH = 62;
558 enum DTV_STAT_CNR = 63;
559 enum DTV_STAT_PRE_ERROR_BIT_COUNT = 64;
560 enum DTV_STAT_PRE_TOTAL_BIT_COUNT = 65;
561 enum DTV_STAT_POST_ERROR_BIT_COUNT = 66;
562 enum DTV_STAT_POST_TOTAL_BIT_COUNT = 67;
563 enum DTV_STAT_ERROR_BLOCK_COUNT = 68;
564 enum DTV_STAT_TOTAL_BLOCK_COUNT = 69;
565 
566 /* Physical layer scrambling */
567 enum DTV_SCRAMBLING_SEQUENCE_INDEX = 70;
568 
569 enum DTV_MAX_COMMAND = DTV_SCRAMBLING_SEQUENCE_INDEX;
570 
571 /**
572  * enum fe_pilot - Type of pilot tone
573  *
574  * @PILOT_ON:	Pilot tones enabled
575  * @PILOT_OFF:	Pilot tones disabled
576  * @PILOT_AUTO:	Autodetect pilot tones
577  */
578 enum fe_pilot
579 {
580     PILOT_ON = 0,
581     PILOT_OFF = 1,
582     PILOT_AUTO = 2
583 }
584 
585 /**
586  * enum fe_rolloff - Rolloff factor
587  * @ROLLOFF_35:		Roloff factor: α=35%
588  * @ROLLOFF_20:		Roloff factor: α=20%
589  * @ROLLOFF_25:		Roloff factor: α=25%
590  * @ROLLOFF_AUTO:	Auto-detect the roloff factor.
591  *
592  * .. note:
593  *
594  *    Roloff factor of 35% is implied on DVB-S. On DVB-S2, it is default.
595  */
596 enum fe_rolloff
597 {
598     ROLLOFF_35 = 0,
599     ROLLOFF_20 = 1,
600     ROLLOFF_25 = 2,
601     ROLLOFF_AUTO = 3
602 }
603 
604 /**
605  * enum fe_delivery_system - Type of the delivery system
606  *
607  * @SYS_UNDEFINED:
608  *	Undefined standard. Generally, indicates an error
609  * @SYS_DVBC_ANNEX_A:
610  *	Cable TV: DVB-C following ITU-T J.83 Annex A spec
611  * @SYS_DVBC_ANNEX_B:
612  *	Cable TV: DVB-C following ITU-T J.83 Annex B spec (ClearQAM)
613  * @SYS_DVBC_ANNEX_C:
614  *	Cable TV: DVB-C following ITU-T J.83 Annex C spec
615  * @SYS_ISDBC:
616  *	Cable TV: ISDB-C (no drivers yet)
617  * @SYS_DVBT:
618  *	Terrestrial TV: DVB-T
619  * @SYS_DVBT2:
620  *	Terrestrial TV: DVB-T2
621  * @SYS_ISDBT:
622  *	Terrestrial TV: ISDB-T
623  * @SYS_ATSC:
624  *	Terrestrial TV: ATSC
625  * @SYS_ATSCMH:
626  *	Terrestrial TV (mobile): ATSC-M/H
627  * @SYS_DTMB:
628  *	Terrestrial TV: DTMB
629  * @SYS_DVBS:
630  *	Satellite TV: DVB-S
631  * @SYS_DVBS2:
632  *	Satellite TV: DVB-S2
633  * @SYS_TURBO:
634  *	Satellite TV: DVB-S Turbo
635  * @SYS_ISDBS:
636  *	Satellite TV: ISDB-S
637  * @SYS_DAB:
638  *	Digital audio: DAB (not fully supported)
639  * @SYS_DSS:
640  *	Satellite TV: DSS (not fully supported)
641  * @SYS_CMMB:
642  *	Terrestrial TV (mobile): CMMB (not fully supported)
643  * @SYS_DVBH:
644  *	Terrestrial TV (mobile): DVB-H (standard deprecated)
645  */
646 enum fe_delivery_system
647 {
648     SYS_UNDEFINED = 0,
649     SYS_DVBC_ANNEX_A = 1,
650     SYS_DVBC_ANNEX_B = 2,
651     SYS_DVBT = 3,
652     SYS_DSS = 4,
653     SYS_DVBS = 5,
654     SYS_DVBS2 = 6,
655     SYS_DVBH = 7,
656     SYS_ISDBT = 8,
657     SYS_ISDBS = 9,
658     SYS_ISDBC = 10,
659     SYS_ATSC = 11,
660     SYS_ATSCMH = 12,
661     SYS_DTMB = 13,
662     SYS_CMMB = 14,
663     SYS_DAB = 15,
664     SYS_DVBT2 = 16,
665     SYS_TURBO = 17,
666     SYS_DVBC_ANNEX_C = 18
667 }
668 
669 /* backward compatibility definitions for delivery systems */
670 enum SYS_DVBC_ANNEX_AC = fe_delivery_system_t.SYS_DVBC_ANNEX_A;
671 enum SYS_DMBTH = fe_delivery_system_t.SYS_DTMB; /* DMB-TH is legacy name, use DTMB */
672 
673 /* ATSC-MH specific parameters */
674 
675 /**
676  * enum atscmh_sccc_block_mode - Type of Series Concatenated Convolutional
677  *				 Code Block Mode.
678  *
679  * @ATSCMH_SCCC_BLK_SEP:
680  *	Separate SCCC: the SCCC outer code mode shall be set independently
681  *	for each Group Region (A, B, C, D)
682  * @ATSCMH_SCCC_BLK_COMB:
683  *	Combined SCCC: all four Regions shall have the same SCCC outer
684  *	code mode.
685  * @ATSCMH_SCCC_BLK_RES:
686  *	Reserved. Shouldn't be used.
687  */
688 enum atscmh_sccc_block_mode
689 {
690     ATSCMH_SCCC_BLK_SEP = 0,
691     ATSCMH_SCCC_BLK_COMB = 1,
692     ATSCMH_SCCC_BLK_RES = 2
693 }
694 
695 /**
696  * enum atscmh_sccc_code_mode - Type of Series Concatenated Convolutional
697  *				Code Rate.
698  *
699  * @ATSCMH_SCCC_CODE_HLF:
700  *	The outer code rate of a SCCC Block is 1/2 rate.
701  * @ATSCMH_SCCC_CODE_QTR:
702  *	The outer code rate of a SCCC Block is 1/4 rate.
703  * @ATSCMH_SCCC_CODE_RES:
704  *	Reserved. Should not be used.
705  */
706 enum atscmh_sccc_code_mode
707 {
708     ATSCMH_SCCC_CODE_HLF = 0,
709     ATSCMH_SCCC_CODE_QTR = 1,
710     ATSCMH_SCCC_CODE_RES = 2
711 }
712 
713 /**
714  * enum atscmh_rs_frame_ensemble - Reed Solomon(RS) frame ensemble.
715  *
716  * @ATSCMH_RSFRAME_ENS_PRI:	Primary Ensemble.
717  * @ATSCMH_RSFRAME_ENS_SEC:	Secondary Ensemble.
718  */
719 enum atscmh_rs_frame_ensemble
720 {
721     ATSCMH_RSFRAME_ENS_PRI = 0,
722     ATSCMH_RSFRAME_ENS_SEC = 1
723 }
724 
725 /**
726  * enum atscmh_rs_frame_mode - Reed Solomon (RS) frame mode.
727  *
728  * @ATSCMH_RSFRAME_PRI_ONLY:
729  *	Single Frame: There is only a primary RS Frame for all Group
730  *	Regions.
731  * @ATSCMH_RSFRAME_PRI_SEC:
732  *	Dual Frame: There are two separate RS Frames: Primary RS Frame for
733  *	Group Region A and B and Secondary RS Frame for Group Region C and
734  *	D.
735  * @ATSCMH_RSFRAME_RES:
736  *	Reserved. Shouldn't be used.
737  */
738 enum atscmh_rs_frame_mode
739 {
740     ATSCMH_RSFRAME_PRI_ONLY = 0,
741     ATSCMH_RSFRAME_PRI_SEC = 1,
742     ATSCMH_RSFRAME_RES = 2
743 }
744 
745 /**
746  * enum atscmh_rs_code_mode
747  * @ATSCMH_RSCODE_211_187:	Reed Solomon code (211,187).
748  * @ATSCMH_RSCODE_223_187:	Reed Solomon code (223,187).
749  * @ATSCMH_RSCODE_235_187:	Reed Solomon code (235,187).
750  * @ATSCMH_RSCODE_RES:		Reserved. Shouldn't be used.
751  */
752 enum atscmh_rs_code_mode
753 {
754     ATSCMH_RSCODE_211_187 = 0,
755     ATSCMH_RSCODE_223_187 = 1,
756     ATSCMH_RSCODE_235_187 = 2,
757     ATSCMH_RSCODE_RES = 3
758 }
759 
760 enum NO_STREAM_ID_FILTER = ~0U;
761 enum LNA_AUTO = ~0U;
762 
763 /**
764  * enum fecap_scale_params - scale types for the quality parameters.
765  *
766  * @FE_SCALE_NOT_AVAILABLE: That QoS measure is not available. That
767  *			    could indicate a temporary or a permanent
768  *			    condition.
769  * @FE_SCALE_DECIBEL: The scale is measured in 0.001 dB steps, typically
770  *		      used on signal measures.
771  * @FE_SCALE_RELATIVE: The scale is a relative percentual measure,
772  *		       ranging from 0 (0%) to 0xffff (100%).
773  * @FE_SCALE_COUNTER: The scale counts the occurrence of an event, like
774  *		      bit error, block error, lapsed time.
775  */
776 enum fecap_scale_params
777 {
778     FE_SCALE_NOT_AVAILABLE = 0,
779     FE_SCALE_DECIBEL = 1,
780     FE_SCALE_RELATIVE = 2,
781     FE_SCALE_COUNTER = 3
782 }
783 
784 /**
785  * struct dtv_stats - Used for reading a DTV status property
786  *
787  * @scale:
788  *	Filled with enum fecap_scale_params - the scale in usage
789  *	for that parameter
790  *
791  * @svalue:
792  *	integer value of the measure, for %FE_SCALE_DECIBEL,
793  *	used for dB measures. The unit is 0.001 dB.
794  *
795  * @uvalue:
796  *	unsigned integer value of the measure, used when @scale is
797  *	either %FE_SCALE_RELATIVE or %FE_SCALE_COUNTER.
798  *
799  * For most delivery systems, this will return a single value for each
800  * parameter.
801  *
802  * It should be noticed, however, that new OFDM delivery systems like
803  * ISDB can use different modulation types for each group of carriers.
804  * On such standards, up to 8 groups of statistics can be provided, one
805  * for each carrier group (called "layer" on ISDB).
806  *
807  * In order to be consistent with other delivery systems, the first
808  * value refers to the entire set of carriers ("global").
809  *
810  * @scale should use the value %FE_SCALE_NOT_AVAILABLE when
811  * the value for the entire group of carriers or from one specific layer
812  * is not provided by the hardware.
813  *
814  * @len should be filled with the latest filled status + 1.
815  *
816  * In other words, for ISDB, those values should be filled like::
817  *
818  *	u.st.stat.svalue[0] = global statistics;
819  *	u.st.stat.scale[0] = FE_SCALE_DECIBEL;
820  *	u.st.stat.value[1] = layer A statistics;
821  *	u.st.stat.scale[1] = FE_SCALE_NOT_AVAILABLE (if not available);
822  *	u.st.stat.svalue[2] = layer B statistics;
823  *	u.st.stat.scale[2] = FE_SCALE_DECIBEL;
824  *	u.st.stat.svalue[3] = layer C statistics;
825  *	u.st.stat.scale[3] = FE_SCALE_DECIBEL;
826  *	u.st.len = 4;
827  */
828 struct dtv_stats
829 {
830     align (1):
831 
832     ubyte scale; /* enum fecap_scale_params type */
833     union
834     {
835         ulong uvalue; /* for counters and relative scales */
836         long svalue; /* for 0.001 dB measures */
837     }
838 }
839 
840 enum MAX_DTV_STATS = 4;
841 
842 /**
843  * struct dtv_fe_stats - store Digital TV frontend statistics
844  *
845  * @len:	length of the statistics - if zero, stats is disabled.
846  * @stat:	array with digital TV statistics.
847  *
848  * On most standards, @len can either be 0 or 1. However, for ISDB, each
849  * layer is modulated in separate. So, each layer may have its own set
850  * of statistics. If so, stat[0] carries on a global value for the property.
851  * Indexes 1 to 3 means layer A to B.
852  */
853 struct dtv_fe_stats
854 {
855     align (1):
856 
857     ubyte len;
858     dtv_stats[MAX_DTV_STATS] stat;
859 }
860 
861 /**
862  * struct dtv_property - store one of frontend command and its value
863  *
864  * @cmd:		Digital TV command.
865  * @reserved:		Not used.
866  * @u:			Union with the values for the command.
867  * @u.data:		A unsigned 32 bits integer with command value.
868  * @u.buffer:		Struct to store bigger properties.
869  *			Currently unused.
870  * @u.buffer.data:	an unsigned 32-bits array.
871  * @u.buffer.len:	number of elements of the buffer.
872  * @u.buffer.reserved1:	Reserved.
873  * @u.buffer.reserved2:	Reserved.
874  * @u.st:		a &struct dtv_fe_stats array of statistics.
875  * @result:		Currently unused.
876  *
877  */
878 struct dtv_property
879 {
880     align (1):
881 
882     uint cmd;
883     uint[3] reserved;
884 
885     union _Anonymous_0
886     {
887         uint data;
888         dtv_fe_stats st;
889 
890         struct _Anonymous_1
891         {
892             ubyte[32] data;
893             uint len;
894             uint[3] reserved1;
895             void* reserved2;
896         }
897 
898         _Anonymous_1 buffer;
899     }
900 
901     _Anonymous_0 u;
902     int result;
903 }
904 
905 /* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */
906 enum DTV_IOCTL_MAX_MSGS = 64;
907 
908 /**
909  * struct dtv_properties - a set of command/value pairs.
910  *
911  * @num:	amount of commands stored at the struct.
912  * @props:	a pointer to &struct dtv_property.
913  */
914 struct dtv_properties
915 {
916     uint num;
917     dtv_property* props;
918 }
919 
920 /*
921  * When set, this flag will disable any zigzagging or other "normal" tuning
922  * behavior. Additionally, there will be no automatic monitoring of the lock
923  * status, and hence no frontend events will be generated. If a frontend device
924  * is closed, this flag will be automatically turned off when the device is
925  * reopened read-write.
926  */
927 enum FE_TUNE_MODE_ONESHOT = 0x01;
928 
929 /* Digital TV Frontend API calls */
930 
931 enum FE_GET_INFO = _IOR!dvb_frontend_info('o', 61);
932 
933 enum FE_DISEQC_RESET_OVERLOAD = _IO('o', 62);
934 enum FE_DISEQC_SEND_MASTER_CMD = _IOW!dvb_diseqc_master_cmd('o', 63);
935 enum FE_DISEQC_RECV_SLAVE_REPLY = _IOR!dvb_diseqc_slave_reply('o', 64);
936 enum FE_DISEQC_SEND_BURST = _IO('o', 65); /* fe_sec_mini_cmd_t */
937 
938 enum FE_SET_TONE = _IO('o', 66); /* fe_sec_tone_mode_t */
939 enum FE_SET_VOLTAGE = _IO('o', 67); /* fe_sec_voltage_t */
940 enum FE_ENABLE_HIGH_LNB_VOLTAGE = _IO('o', 68); /* int */
941 
942 enum FE_READ_STATUS = _IOR!fe_status('o', 69);
943 enum FE_READ_BER = _IOR!uint('o', 70);
944 enum FE_READ_SIGNAL_STRENGTH = _IOR!ushort('o', 71);
945 enum FE_READ_SNR = _IOR!ushort('o', 72);
946 enum FE_READ_UNCORRECTED_BLOCKS = _IOR!uint('o', 73);
947 
948 enum FE_SET_FRONTEND_TUNE_MODE = _IO('o', 81); /* unsigned int */
949 enum FE_GET_EVENT = _IOR!dvb_frontend_event('o', 78);
950 
951 enum FE_DISHNETWORK_SEND_LEGACY_CMD = _IO('o', 80); /* unsigned int */
952 
953 enum FE_SET_PROPERTY = _IOW!dtv_properties('o', 82);
954 enum FE_GET_PROPERTY = _IOR!dtv_properties('o', 83);
955 
956 /*
957  * DEPRECATED: Everything below is deprecated in favor of DVBv5 API
958  *
959  * The DVBv3 only ioctls, structs and enums should not be used on
960  * newer programs, as it doesn't support the second generation of
961  * digital TV standards, nor supports newer delivery systems.
962  * They also don't support modern frontends with usually support multiple
963  * delivery systems.
964  *
965  * Drivers shouldn't use them.
966  *
967  * New applications should use DVBv5 delivery system instead
968  */
969 
970 /*
971  */
972 
973 enum fe_bandwidth
974 {
975     BANDWIDTH_8_MHZ = 0,
976     BANDWIDTH_7_MHZ = 1,
977     BANDWIDTH_6_MHZ = 2,
978     BANDWIDTH_AUTO = 3,
979     BANDWIDTH_5_MHZ = 4,
980     BANDWIDTH_10_MHZ = 5,
981     BANDWIDTH_1_712_MHZ = 6
982 }
983 
984 /* This is kept for legacy userspace support */
985 alias fe_sec_voltage_t = fe_sec_voltage;
986 alias fe_caps_t = fe_caps;
987 alias fe_type_t = fe_type;
988 alias fe_sec_tone_mode_t = fe_sec_tone_mode;
989 alias fe_sec_mini_cmd_t = fe_sec_mini_cmd;
990 alias fe_status_t = fe_status;
991 alias fe_spectral_inversion_t = fe_spectral_inversion;
992 alias fe_code_rate_t = fe_code_rate;
993 alias fe_modulation_t = fe_modulation;
994 alias fe_transmit_mode_t = fe_transmit_mode;
995 alias fe_bandwidth_t = fe_bandwidth;
996 alias fe_guard_interval_t = fe_guard_interval;
997 alias fe_hierarchy_t = fe_hierarchy;
998 alias fe_pilot_t = fe_pilot;
999 alias fe_rolloff_t = fe_rolloff;
1000 alias fe_delivery_system_t = fe_delivery_system;
1001 
1002 /* DVBv3 structs */
1003 
1004 struct dvb_qpsk_parameters
1005 {
1006     uint symbol_rate; /* symbol rate in Symbols per second */
1007     fe_code_rate_t fec_inner; /* forward error correction (see above) */
1008 }
1009 
1010 struct dvb_qam_parameters
1011 {
1012     uint symbol_rate; /* symbol rate in Symbols per second */
1013     fe_code_rate_t fec_inner; /* forward error correction (see above) */
1014     fe_modulation_t modulation; /* modulation type (see above) */
1015 }
1016 
1017 struct dvb_vsb_parameters
1018 {
1019     fe_modulation_t modulation; /* modulation type (see above) */
1020 }
1021 
1022 struct dvb_ofdm_parameters
1023 {
1024     fe_bandwidth_t bandwidth;
1025     fe_code_rate_t code_rate_HP; /* high priority stream code rate */
1026     fe_code_rate_t code_rate_LP; /* low priority stream code rate */
1027     fe_modulation_t constellation; /* modulation type (see above) */
1028     fe_transmit_mode_t transmission_mode;
1029     fe_guard_interval_t guard_interval;
1030     fe_hierarchy_t hierarchy_information;
1031 }
1032 
1033 struct dvb_frontend_parameters
1034 {
1035     uint frequency; /* (absolute) frequency in Hz for DVB-C/DVB-T/ATSC */
1036     /* intermediate frequency in kHz for DVB-S */
1037     fe_spectral_inversion_t inversion;
1038 
1039     /* DVB-S */
1040     /* DVB-C */
1041     /* DVB-T */
1042     /* ATSC */
1043     union _Anonymous_2
1044     {
1045         dvb_qpsk_parameters qpsk;
1046         dvb_qam_parameters qam;
1047         dvb_ofdm_parameters ofdm;
1048         dvb_vsb_parameters vsb;
1049     }
1050 
1051     _Anonymous_2 u;
1052 }
1053 
1054 struct dvb_frontend_event
1055 {
1056     fe_status_t status;
1057     dvb_frontend_parameters parameters;
1058 }
1059 
1060 /* DVBv3 API calls */
1061 
1062 enum FE_SET_FRONTEND = _IOW!dvb_frontend_parameters('o', 76);
1063 enum FE_GET_FRONTEND = _IOR!dvb_frontend_parameters('o', 77);
1064 
1065 /*_DVBFRONTEND_H_*/